import { axios } from '@/utils/request'
import { WordDownLoad } from '@/myService/FileDownLoad'

let baseUrl="/epa-manage";

export default {
  getList: function (params) {
    return axios({
      url: baseUrl+"/Statistics/currentPage",
      method: "GET",
      params: params
    })
  },

  getListSearch:function (params){
    return axios({
      url: baseUrl+"/Statistics/Search",
      method:"GET",
      params: params
    })
  },

  addEpaWeekly: function (data){
    return axios({
      url: baseUrl+"/Statistics/addEpaWeekly",
      method:"POST",
      data:data
    })
  },

  updataEpaWeekly: function (data){
    return axios({
      url: baseUrl+"/Statistics/updataEpaWeekly",
      method:"POST",
      data:data
    })
  },

  getCategory: function (params){
    return axios({
      url: baseUrl+"/Statistics/getCategory",
      method:"GET",
      params:params
    })
  },

  getEpaArea: function (params){
    return axios({
      url: baseUrl+"/Statistics/getEpaArea",
      method:"GET",
      params:params
    })
  },

  getFocusOrder: function (params){
    return axios({
      url: baseUrl+"/Statistics/getFocusOrder",
      method:"GET",
      params:params
    })
  },

  uploadExcel: function (data) {
    return axios({
      url: baseUrl + "/Statistics/addExcel",
      method: 'post',
      data: data,
      headers: {
        'Content-Type': 'multipart/form-data'
      }
    })
  },

  getXfj: function (data) {
    return axios({
      url: baseUrl + "/Statistics/currentPageXfj",
      method: 'post',
      data: data
    })
  },

  addZdj: function (data) {
    return axios({
      url: baseUrl + "/Statistics/addZdj",
      method: 'post',
      data: data
    })
  },

  deleteZdj: function (params) {
    return axios({
      url: baseUrl + "/Statistics/deleteZdj",
      method:"GET",
      params:params
    })
  },
  // createWord: function (params) {
  //   return axios({
  //     url: baseUrl + "/Statistics/createWord",
  //     method:"GET",
  //     params:params
  //   })
  // },

  endEpa: function (params) {
    return axios({
      url: baseUrl + "/Statistics/endEpa",
      method:"GET",
      params:params
    })
  },
  createWord: function (params){
    return axios({
      url: baseUrl+"/Statistics/createWord",
      method: "GET",
      params: params,
      responseType:'blob',
    }).then(res => {
      WordDownLoad(res)
      // console.log(res)
      // //切割出文件名
      // const fileNameEncode = (res.headers['content-disposition'] || '').split('filename=')[1]
      // //解码
      // const fileName = decodeURIComponent(fileNameEncode)
      // // 设置type类型
      // const blob = new Blob([res.data], {
      //   type: 'application/msword; charset=utf-8'
      // })
      // const link = document.createElement('a')
      // link.style.display = "none";
      // link.href = URL.createObjectURL(blob);
      // link.setAttribute('download', `${fileName}`)
      // document.body.appendChild(link);
      // link.click();
      // document.body.removeChild(link);
    })
  },
  previewWord:function (params){
    return axios({
      url: baseUrl + "/Statistics/createWord",
      method:"GET",
      params:params,
      responseType:'blob',
    })
  },

  deleteStatistics:function (params){
    return axios({
      url: baseUrl + "/Statistics/deleteStatistics",
      method:"GET",
      params:params,
    })
  }
}